<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>03.键盘事件</title>
  </head>

  <body>
    <div id="app">
      <h2>{{msg}}</h2>
      <input type="text" placeholder="请输入" @keyup.enter="showInfo">
    </div>
  </body>
  <script src="../js/vue.js"></script>
  <script>
    /* 
    vue事件里的常用别名
      .enter:
      .tab
      .delete (捕获“删除”和“退格”键)
      .esc
      .space
      .up
      .down
      .left
      .right
    
    */
    new Vue({
      el: "#app",
      data: {
        msg: "Vue"
      },
      methods: {
        showInfo(e) {
          // 通过e.keyCode拿到13，enter的keyCode码就是13
          // if (e.keyCode !== 13) return
          console.log(e.target.value);
        }
      }
    })
  </script>

</html>